package com.example.work2

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class MainActivity2 : AppCompatActivity() {

    private lateinit var textViewName: TextView
    private lateinit var textViewGender: TextView
    private lateinit var textViewPhone: TextView
    private lateinit var textViewHighScore: TextView
    private lateinit var buttonEditInfo: Button

    @SuppressLint("MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        textViewName = findViewById(R.id.textViewName)
        textViewGender = findViewById(R.id.textViewGender)
        textViewPhone = findViewById(R.id.textViewPhone)
        textViewHighScore = findViewById(R.id.textViewHighScore)
        buttonEditInfo = findViewById(R.id.buttonEditInfo)


        val playerInfo = PlayerInfo("刘渝铭", "男", "1234567890", 10)

        textViewName.text = "${playerInfo.name} ${textViewName.text}"
        textViewGender.text = "${playerInfo.gender} ${textViewGender.text}"
        textViewPhone.text = "${playerInfo.phone} ${textViewPhone.text}"
        textViewHighScore.text = "${playerInfo.highScore} ${textViewHighScore.text}"

        buttonEditInfo.setOnClickListener {
            val intent = Intent(this, MainActivity3::class.java)
            startActivity(intent)
        }
    }
}

data class PlayerInfo(
    var name: String,
    var gender: String,
    var phone: String,
    var highScore: Int
)